; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -O3 -mtriple=riscv64 -riscv-enable-copy-propagation=false | FileCheck %s --check-prefix=NOPROP
; RUN: llc < %s -O3 -mtriple=riscv64 -riscv-enable-copy-propagation=true | FileCheck %s --check-prefix=PROP

define void @copyprop_after_mbp(i32 %v, i32* %a, i32* %b, i32* %c, i32* %d) {
; NOPROP-LABEL: copyprop_after_mbp:
; NOPROP:       # %bb.0:
; NOPROP-NEXT:    sext.w a0, a0
; NOPROP-NEXT:    li a5, 10
; NOPROP-NEXT:    bne a0, a5, .LBB0_2
; NOPROP-NEXT:  # %bb.1: # %bb.0
; NOPROP-NEXT:    li a0, 15
; NOPROP-NEXT:    sw a0, 0(a2)
; NOPROP-NEXT:    li a0, 1
; NOPROP-NEXT:    sw a0, 0(a1)
; NOPROP-NEXT:    li a0, 12
; NOPROP-NEXT:    sw a0, 0(a4)
; NOPROP-NEXT:    ret
; NOPROP-NEXT:  .LBB0_2: # %bb.1
; NOPROP-NEXT:    li a0, 0
; NOPROP-NEXT:    li a2, 25
; NOPROP-NEXT:    sw a2, 0(a3)
; NOPROP-NEXT:    sw a0, 0(a1)
; NOPROP-NEXT:    li a0, 12
; NOPROP-NEXT:    sw a0, 0(a4)
; NOPROP-NEXT:    ret
;
; PROP-LABEL: copyprop_after_mbp:
; PROP:       # %bb.0:
; PROP-NEXT:    sext.w a0, a0
; PROP-NEXT:    li a5, 10
; PROP-NEXT:    bne a0, a5, .LBB0_2
; PROP-NEXT:  # %bb.1: # %bb.0
; PROP-NEXT:    li a0, 15
; PROP-NEXT:    sw a0, 0(a2)
; PROP-NEXT:    li a0, 1
; PROP-NEXT:    sw a0, 0(a1)
; PROP-NEXT:    li a0, 12
; PROP-NEXT:    sw a0, 0(a4)
; PROP-NEXT:    ret
; PROP-NEXT:  .LBB0_2: # %bb.1
; PROP-NEXT:    li a2, 25
; PROP-NEXT:    sw a2, 0(a3)
; PROP-NEXT:    sw zero, 0(a1)
; PROP-NEXT:    li a0, 12
; PROP-NEXT:    sw a0, 0(a4)
; PROP-NEXT:    ret
  %1 = icmp eq i32 %v, 10
  br i1 %1, label %bb.0, label %bb.1

bb.0:
  store i32 15, i32* %b, align 4
  br label %bb.2

bb.1:
  store i32 25, i32* %c, align 4
  br label %bb.2

bb.2:
  %2 = phi i32 [ 1, %bb.0 ], [ 0, %bb.1 ]
  store i32 %2, i32* %a, align 4
  store i32 12, i32* %d, align 4
  ret void
}
